from datetime import timedelta
import os

# 数据库配置
HOST_NAME = '127.0.0.1'
PORT = 3306
USERNAME = 'root'
PASSWORD = '123456'
DATABASE = 'forum_database'
SQLALCHEMY_DATABASE_URI = f'mysql+pymysql://{USERNAME}:{PASSWORD}@{HOST_NAME}:{PORT}/{DATABASE}?charset=utf8'
SQLALCHEMY_TRACK_MODIFICATIONS = False

# 邮箱配置
# MAIL_USE_TLS 端口587
# MAIL_USE_SSL 端口465
# qq邮箱不支持非加密方式发送邮箱
# 发送者邮箱的服务地址
MAIL_SERVER = 'smtp.qq.com'
MAIL_PORT = 587
MAIL_USE_TLS = True
MAIL_USERNAME = '3034026545@qq.com'
MAIL_PASSWORD = 'jrsrlubqbuqgdfab'
MAIL_DEFAULT_SENDER = '3034026545@qq.com'

# celery和redis配置
CELERY_BROKER_URL = 'redis://127.0.0.1:6379/0'
CELERY_RESULT_BACKEND = 'redis://127.0.0.1:6379/0'

# Flask-Caching配置
CACHE_TYPE = 'RedisCache'
CACHE_DEFAULT_TIMEOUT = 300
CACHE_REDIS_HOST = '127.0.0.1'
CACHE_REDIS_PORT = 6379

# CSRF使用的要求必须有
SECRET_KEY = '1234567890'

# 获取当前文件所在目录
BASE_DIR = os.path.dirname(__file__)

# 设置cookie过期时间
PERMANENT_SESSION_LIFETIME = timedelta(days=7)

# 头像配置
AVATARS_SAVE_PATH = os.path.join(BASE_DIR, 'media/avatars')

# 帖子上传路径
POST_IMAGE_SAVE_PATH = os.path.join(BASE_DIR, 'media/post')

# 轮播图传路径
BANNER_IMAGE_SAVE_PATH = os.path.join(BASE_DIR, 'media/banner')

# 每页展示帖子数量
PER_PAGE_COUNT = 10

# 设置jwt过期时间
JWT_ACCESS_TOKEN_EXPIRES = timedelta(days=7)
